package com.kmxd.ams.core.oss.properties;

import io.minio.MinioClient;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;import java.util.Map;

/**
 * oss配置信息
 *
 * @author ZuoLG
 */
@Data
@ConfigurationProperties(prefix = OssProperties.PREFIX)
public class OssProperties {

  /** 配置前缀 */
  public static final String PREFIX = "oss";

  /** 是否启用 oss，默认为：false */
  private boolean enable = false;

  /** 上传文件位置 */
  private String uploadType;

  /** minio路径地址 */
  private String endpoint;

  /** minio accessKey */
  private String accessKey;

  /** minio secretKey */
  private String secretKey;

  /** minio bucketName */
  private String bucketName;

  /** 公共附件文件路径 */
  private String attachment = "/other";
  /** 收集整编库 */
  private String collect = "/collect";
  /** 归档库 */
  private String manage = "/manage";
  /** 临时文件 */
  private String temp = "/temp";

  private String backup = "/backup";

  private String aip = "/aip";

  private String ocr = "/ocr";

  /** 当前使用路径 */
  private String defPath = "uploads";

  /** 路径列表 */
  private Map<String, String> paths;

  /** 公共附件的细分目录 */
  private final AttachmentSubPath attachmentSubPath = new AttachmentSubPath();

  /**
   * minio对象注入
   *
   * @return
   */
  @Bean
  MinioClient minioClient() {
    return MinioClient.builder().endpoint(endpoint).credentials(accessKey, secretKey).build();
  }
}
